package siwi.map.android;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.wmw.Animation.ViewAction;
import com.wmw.DataPool.CommonData;
import com.wmw.Utility.Common;
import com.wmw.Utility.RegularExpression;

public class Feedback extends SherlockActivity {
	InputBox _input;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.feedback);

		initActionBar();
		initViews();
		initData();
	}

	private void initActionBar() {
		// Custom action bar.
		ActionBar actionBar = getSupportActionBar();
		ActionBar.LayoutParams params = new ActionBar.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
				Gravity.CENTER);
		View view = LayoutInflater.from(this).inflate(
				R.layout.action_bar_back_save, null);
		actionBar.setCustomView(view, params);
		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
		actionBar.setDisplayShowCustomEnabled(true);

		findViewById(R.id.ABBS_Save).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Common.toastInfo(Feedback.this, "通知反馈");
				goBack();
				return;
			}

		});
		findViewById(R.id.ABBS_Back).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				ViewAction.startSpringMenuAnimations(v);
				// Go back.
				Log.d(Common.GetLineInfo(), "Go back without saving");
				goBack();
				return;
			}
		});

		TextView tv = (TextView) view.findViewById(R.id.ABBS_Title);
		tv.setText("反馈");
	}

	private void initViews() {

		final EditText etContent = (EditText) findViewById(R.id.F_Content);
		TextView leftCnt = (TextView) findViewById(R.id.F_Count);
		_input = new InputBox(this, etContent, null, leftCnt,
				etContent.getPaddingRight(), RegularExpression.Normal,
				new InputBox.ShakeBox() {
					@Override
					public void Action(EditText et, String regularExpression,
							Context context, View v, boolean hasFocus) {
						super.Action(et, regularExpression, context, v,
								hasFocus);
					}

					@Override
					public void OnFocusChange(boolean valide, boolean hasFocus) {
						super.OnFocusChange(valide, hasFocus);
						Log.d(Common.GetLineInfo(), "Focus -" + hasFocus);
						if (hasFocus)
							etContent.setBackgroundColor(Feedback.this
									.getResources().getColor(
											R.color.TextBackground));
						else if (valide)
							etContent.setBackgroundColor(Feedback.this
									.getResources().getColor(
											R.color.Transparent));
					}
				});

	}

	private void initData() {
	}

	private void goBack() {
		Intent intent = new Intent();
		intent.setClass(Feedback.this, Home.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		startActivity(intent);
		overridePendingTransition(R.anim.left_in, R.anim.right_out);
		finish();
	}
}
